﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_PzRuleSet_OperType_Grid.aspx.vb" Inherits="PubProject.Cwjk_PzRuleSet_OperType_Grid" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head runat="server">
    <title>业务类型</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
	<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
	<meta content="JavaScript" name="vs_defaultClientScript">
	<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
	<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
	<script language="javascript" src="/_common/scripts/global.js"></script>
	<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
	<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
	<script language="javascript" src="/_controls/settings.aspx"></script>
	<script language="javascript" src="/_controls/util/util.js"></script>
	<script language="javascript" src="/_nav/menu.js"></script>		
	<!-- GridTree -->
	<link rel="stylesheet" type="text/css" href="/_controls/tree/gridtree.css">
	<script language="javascript" src="/PubProject/js/Public.js"></script>
	<script language="javascript" src="/PubProject/Cwjk/Cwjk_Public.js"></script>
	<script language="javascript">
	    var strOldHierarchyCode= "";
	    var _MyHelpfile = "/Cbgl/HELP/topics/财务人员/设置财务接口/设置凭证规则.html";
	    function document.onkeydown()
        {
            try
            {
                if (event.keyCode == 8)
                {
                    var s = event.srcElement.tagName;
                    if (s && s != "INPUT" && s != "TEXTAREA") 
                    {
                        event.returnValue = false;
                    }
                    else if (event.srcElement.type != "text")
                    {
                        event.returnValue = false;
                    }
                    else if (event.srcElement.readOnly)
                    {
                        event.returnValue = false;
                    }
                }
            }
            catch(e){}
        }
	    function window.onload()
	    {
		    //将禁用的业务场景显示为灰色，只有“显示全部”时才需要处理
		    var strIsAll = "0";
		    var strHierarchyCode = "";
		    if(document.all["__IsAll"])
		    {
		        strIsAll = document.all["__IsAll"].value;
		    }
		    if (document.all["__HierarchyCode"])
		    {
		        strHierarchyCode = document.all["__HierarchyCode"].value;
		    }
		    if(strIsAll == "1")
	        {
	            setOperTypeColor();
	        }
	        //设置默认选中的业务场景
	        SetDefaultOperType(strHierarchyCode,strIsAll);
	        
            var arrRows = appGridTree.getRows();
            if (arrRows.length == 0)
            {
                parent.showPzEntryGrid("");
            }
	        if (document.all["__Application"] && document.all["__Application"].value == "0101")
	        {
	            _MyHelpfile = "/Slxt/Help/topics/财务管理/财务接口设置/设置凭证规则.html";
	        }
	    }
	    function setOperTypeColor()
	    {
	        // 循环所有行
			var arrTr = appGridTree.getRows();
			if ( arrTr )
			{				
				for (var i=0; i < arrTr.length; i++)
				{	
					if (arrTr[i].IsDisable == "True") arrTr[i].cells[0].style.color = "gray";
				}
			}
	    }
	    //
	    function SetDefaultOperType(strHierarchyCode)
	    {
	        if (strHierarchyCode == "")
	        {
	            var arrTr = appGridTree.getRows();
	            var strFirstOperTypeCode = "";
			    if ( arrTr )
			    {
				    for (var i=0; i < arrTr.length; i++)
				    {
				        //找到第一个业务场景
				        if (strFirstOperTypeCode == "" && arrTr[i].OperTypeLevel == "2")
				        {
				            strFirstOperTypeCode = arrTr[i].HierarchyCode;
				            if (strHierarchyCode == "")
				            {
				                break;
				            }
				        }
				        //如果列表中存在定位的业务场景，则定位到该场景
					    if (arrTr[i].HierarchyCode == strHierarchyCode)
					    {
					        strFirstOperTypeCode = strHierarchyCode;
					        break;
					    }
				    }
			    }
			    appGridTree.selectByLevel(strFirstOperTypeCode);
	        }
	        else
	        {
	            appGridTree.selectByLevel(strHierarchyCode);
	        }
	        
	    }
	    function trClick(obj)
	    {
	        //不能选择业务分类
	        var arrTr = appGridTree.selectedRow;
	        if (arrTr)
	        {
	            parent.document.all["tdErrorEntry"].bgColor = "#EFEFEB";
	            if (strOldHierarchyCode == arrTr.HierarchyCode) 
	            {
	                //return;
	            }
	            if (arrTr.OperTypeLevel == "2")
	            {
	                if (arrTr.IsAddible == "True")
	                {
	                    reDisplay("cAdd")
	                }
	                else
	                {
	                    deDisplay("cAdd");
	                }
	                if (arrTr.IsSys == "True")
	                {
	                    deDisplay("cDelete");
	                }
	                else
	                {
	                    reDisplay("cDelete");
	                }
	                if (arrTr.IsDisable == "True")
	                {
	                    reDisplay("cEnabled");
	                    deDisplay("cDisabled");
	                }
	                else
	                {
	                    reDisplay("cDisabled");
	                    deDisplay("cEnabled");
	                }
	                strOldHierarchyCode = arrTr.HierarchyCode;
	                parent.showPzEntryGrid(arrTr.oid);
	            }
	            else
	            {
	                appGridTree.selectByLevel(strOldHierarchyCode);
	            }
	        }
	    }
	    //新增业务场景
	    function addOperType()
	    {
	        var arrTr = appGridTree.selectedRow;
	        if (arrTr)
	        {
	            if (arrTr.OperTypeLevel == "1") return;
	            var strCwztGUID,strApplication,strHierarchyCode;
	            strCwztGUID = document.all["__CwztGUID"].value;
	            strApplication = document.all["__Application"].value;
	            strHierarchyCode = arrTr.HierarchyCode;
	            var strPath = "/PubProject/Cwjk/Cwjk_PzRuleSet_OperType_Edit.aspx";
	            var strParam = "CwztGUID=" + strCwztGUID + "&Application=" + strApplication + "&HierarchyCode=" + strHierarchyCode
	            var sNewHierarchyCode = openMyDlg("新增业务场景", strPath, strParam, "", 400, 180);
                if (sNewHierarchyCode  != undefined)
                {
                    //执行主界面刷新
					try
					{
						parent.opener.window.RefreshWindow();
					}
					catch(e)
					{}
					parent.refleshGrid(sNewHierarchyCode);
                }
                
	        }
	        
	    }
	    //删除业务场景
	    function deleteOperType()
	    {
	        var arrTr = appGridTree.selectedRow;
	        if (arrTr)
	        {
	            if (arrTr.OperTypeLevel == "1") return;
	            if (confirm("确实要删除选择的业务场景吗？"))
	            {	        
	                var strOperTypeGUID,strIsAll;
	                var sCwztGUID = document.all["__CwztGUID"].value;
	                strOperTypeGUID = arrTr.oid;
	                strIsAll = document.all["__IsAll"].value;
    	            
	                var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
		            sFile += "?OperTypeGUID=" + strOperTypeGUID + "&IsAll=" + strIsAll ;
		            var sReturns = "";
		            sReturns = openCwjkXmlHTTP(sFile,"DeleteOperType","");
		            if (sReturns != undefined)
		            {
						try
						{
							window.parent.frames["ifrmEntry"].document.all["txtIsPrompt"].value = "0";
							
							sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx?CwztGUID=" + sCwztGUID;
							var sRtn = openCwjkXmlHTTP(sFile,"GetErrorPzCount");
							if(sRtn!=undefined)
							{
								window.parent.document.all["lbl_ErrorPzNum"].innerText = sRtn;
							}
						}
						catch(e){}
		                var arrRtn = sReturns.split("|")
		                if (arrRtn.length ==2)
		                {
		                    if (arrRtn[0] =="YES")
		                    {
		                        //执行主界面刷新
					            try
					            {
						            parent.opener.window.RefreshWindow();
					            }
					            catch(e)
					            {}
					            parent.refleshGrid(arrRtn[1]);
	                        }
	                        else
	                        {
	                            alert(arrRtn[1]);
	                        }
		                }
		                else
		                {
		                    alert("系统错误，请联系管理员！");
		                }
		            }
		            else
		            {
		                alert("系统错误，请联系管理员！");
		            }
		        }
	        }
	        else
	        {
	            alert("请选择业务场景！");
	        }
	    }
	    //启用业务场景
	    function enabledOperType()
	    {
	        var arrTr = appGridTree.selectedRow;
	        if (arrTr)
	        {
	            if (arrTr.OperTypeLevel == "1") return;
	            var sCwztGUID = document.all["__CwztGUID"].value;
                var sApplication = document.all["__Application"].value;
                var sHierarchyCode = arrTr.HierarchyCode;
                var sUsedScope = arrTr.UsedScope;
                var sFile = "";
	            if (arrTr.IsUsedScopeRepeat == "False" && arrTr.UsedScope != "")
	            {
	                sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
	                sFile += "?CwztGUID=" + sCwztGUID + "&Application=" + sApplication + "&HierarchyCode=" + sHierarchyCode ;
	                var sReturns = "";
	                sReturns = openCwjkXmlHTTP(sFile,"CheckUsedScopeRepeat",sUsedScope);
	                if (sReturns != undefined)
		            {
		                var arrRtn = sReturns.split("|")
		                if (arrRtn.length ==2)
		                {
		                    if (arrRtn[0] !="YES")		                    
	                        {
	                            alert("当前业务场景的适用范围与“" + arrRtn[1] + "”业务场景的适用范围重复，不允许启用！");
	                            return;
	                        }
		                }
		                else
		                {
		                    alert("系统错误，请联系管理员！");
		                    return;
		                }
		            }
		            else
		            {
		                alert("系统错误，请联系管理员！");
		                return;
		            }
	            }
	            if(confirm("确实要启用当前选择的业务场景吗？"))
                {
                    sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
                    sFile += "?CwztGUID=" + sCwztGUID + "&Application=" + sApplication + "&OperType=" + escape(arrTr.OperType) ;
                    sFile += "&IsUsedScopeRepeat=" + arrTr.IsUsedScopeRepeat + "&OperTypeGUID="+ arrTr.oid + "&HierarchyCode=" + sHierarchyCode;
                    var sReturns = "";
                    sReturns = openCwjkXmlHTTP(sFile,"EnabledOperType",sUsedScope);
                    if (sReturns != undefined)
                    {
						try
						{
							sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx?CwztGUID=" + sCwztGUID;
							var sRtn = openCwjkXmlHTTP(sFile,"GetErrorPzCount");
							if(sRtn!=undefined)
							{
								window.parent.document.all["lbl_ErrorPzNum"].innerText = sRtn;
							}
						}
						catch(e){}
                        var arrRtn = sReturns.split("|")
                        if (arrRtn.length ==2)
                        {
                            if (arrRtn[0] =="YES")
                            {
                                //执行主界面刷新
					            try
					            {
						            parent.opener.window.RefreshWindow();
					            }
					            catch(e)
					            {}
                                parent.refleshGrid(arrRtn[1]);
                            }
                            else
                            {
                                alert(arrRtn[1]);
                            }
                        }
                        else
                        {
                            alert("系统错误，请联系管理员！");
                        }
                    }
                    else
                    {
                        alert("系统错误，请联系管理员！");
                    }
                }
	        }
	        else
	        {
	            alert("请选择业务场景！");   
	        }
	    }
	    //禁用业务场景
	    function disabledOperType()
	    {
	        var arrTr = appGridTree.selectedRow;
	        if (arrTr)
	        {
	            if (arrTr.OperTypeLevel == "1") return;	        
	            if (confirm("确实要禁用当前选择的业务场景吗？"))
	            {	        
	                var strOperTypeGUID,strIsAll;
	                var sCwztGUID = document.all["__CwztGUID"].value;
	                strOperTypeGUID = arrTr.oid;
	                strIsAll = document.all["__IsAll"].value;
    	            
	                var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
		            sFile += "?OperTypeGUID=" + strOperTypeGUID + "&IsAll=" + strIsAll ;
		            var sReturns = "";
		            sReturns = openCwjkXmlHTTP(sFile,"DisableOperType","");
		            if (sReturns != undefined)
		            {
						try
						{
						    window.parent.frames["ifrmEntry"].document.all["txtIsPrompt"].value = "0";
							sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx?CwztGUID=" + sCwztGUID;
							var sRtn = openCwjkXmlHTTP(sFile,"GetErrorPzCount");
							if(sRtn!=undefined)
							{
								window.parent.document.all["lbl_ErrorPzNum"].innerText = sRtn;
							}
						}
						catch(e){}
		                var arrRtn = sReturns.split("|")
		                if (arrRtn.length ==2)
		                {
		                    if (arrRtn[0] =="YES")
		                    {
		                        //执行主界面刷新
					            try
					            {
						            parent.opener.window.RefreshWindow();
					            }
					            catch(e)
					            {}
		                        parent.refleshGrid(arrRtn[1]);
	                        }
	                        else
	                        {
	                            alert(arrRtn[1]);
	                        }
		                }
		                else
		                {
		                    alert("系统错误，请联系管理员！");
		                }
		            }
		            else
		            {
		                alert("系统错误，请联系管理员！");
		            }
		        }
	        }
	        else
	        {
	            alert("请选择业务场景！");
	        }	    
	    }
	    
	</script>
</head>
<body>
    <form id="form1" runat="server">
    <table style="FONT-SIZE: 9pt" height="100%" cellSpacing="0" cellPadding="0" width="100%">
		<tr height="1">
			<td>
				<mnu:AppGridMenu id="appGridMenu" runat="server" />
			</td>
		</tr>
		<tr>
			<td vAlign="top">				
				<div style="WIDTH:100%; HEIGHT:100%; BACKGROUND-COLOR: white">
					<cnt:appgridtree id="appGridTree" runat="server"></cnt:appgridtree>
				</div>
			</td>
		</tr>
	</table>
    </form>
</body>
</html>
